#include <bits/stdc++.h>
using namespace std;

int t;
int n, m, l, V;
int v[100005];
int d[100005];
int a[100005];
int p[1000005];
int c[100005];
int ans;
int r[100005];

void dfs(int dep, int s)
{
    if (dep == n)
    {
        ans = max(ans, s);
        return ;
    }
    dep++;
    r[dep] = 1;
    for (int i = dep - 1; i >= 1; i--)
        if (r[i] == r[dep] && a[i] == a[dep])
        {
            c[dep] = a[dep];
            break;
        }
    dfs(dep, s + c[dep]);
    c[dep] = 0;
    r[dep] = 2;
    for (int i = dep - 1; i >= 1; i--)
        if (r[i] == r[dep] && a[i] == a[dep])
        {
            c[dep] = a[dep];
            break;
        }
    dfs(dep, s + c[dep]);
    c[dep] = 0;
    r[dep] = 0;
    return ;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> t;
    while (t--)
    {
        cin >> n >> m >> l >> V;
        for (int i = 1; i <= n; i++)
            cin >> d[i] >> v[i] >> a[i];
        for (int i = 1; i <= m; i++)
        {
            int k;
            cin >> k;
            p[k]++;
        }
    }
    return 0;
}
